﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml;

namespace Harrby
{
    public static class XmlConvert
    {
        public static XElement GetXElement(this XmlNode node)
        {
            XDocument xDocument = new XDocument();
            using (XmlWriter xmlWriter = xDocument.CreateWriter())
            {
                node.WriteTo(xmlWriter);
                return xDocument.Root;
            }
        }
        public static XmlNode GetXmlNode(this XElement element)
        {
            using (XmlReader xmlReader = element.CreateReader())
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(xmlReader);
                return xmlDocument;
            }
        }
    }
}
